package com.xyauto.qiehuan;


import android.content.ComponentName;

import android.content.ContentResolver;
import android.content.Intent;
import android.content.ServiceConnection;

import android.database.ContentObserver;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;

import android.view.View;
import android.view.WindowManager;

import android.widget.TextView;


import com.xyauto.service.AuxiliaryService;
import com.xyauto.xfq.R;


import androidx.appcompat.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {
   private TextView speed;
    WindowManager wManager;
    WindowManager.LayoutParams wmParams;
    View views;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        speed=findViewById(R.id.speed);

       /* wManager = (WindowManager) this.getApplication().getSystemService(Context.WINDOW_SERVICE);
        wmParams = new WindowManager.LayoutParams();
        wmParams.type = WindowManager.LayoutParams.TYPE_PHONE;
        wmParams.format = PixelFormat.RGBA_8888;
        wmParams.gravity = Gravity.LEFT | Gravity.TOP;
        wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
        wmParams.alpha = 1;
        wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
        wmParams.height = WindowManager.LayoutParams.FILL_PARENT;

        views = LayoutInflater.from(this).inflate(R.layout.layout_menu_right, null);*/

        /*MyFloatDialog mBaseFloatDailog = new MyFloatDialog(this.getApplication());
        mBaseFloatDailog.show();*/
     //   wManager.addView(views,wmParams);
//
       // startService(new Intent(this, AuxiliaryService.class));

        Intent intent2 = new Intent().setClass(this, AuxiliaryService.class);
        startService(intent2);
      /*  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
            startForegroundService(intent2);
            Log.e("TAG","开机启动startForegroundService");
        } else {
            startService(intent2);
            Log.e("TAG","开机启动startService");
        }*/
       /* ContentResolver contentResolver = getApplicationContext().getContentResolver();
        contentResolver.registerContentObserver(
                Settings.System.getUriFor("volume_music"),
                true, // 观察子项变化
                new ContentObserver(new Handler()) {
                    @Override
                    public void onChange(boolean selfChange) {
                        super.onChange(selfChange);
                        Log.e("TAG", "onChange: --" );

                    }
                });*/



      //  bindService(intent2, new MusicConnection(), Context.BIND_AUTO_CREATE);

     //   finish();
    }
    //连接Service
    private class MusicConnection implements ServiceConnection {

        //This method will be entered after the service is started.
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {

        }

        @Override
        public void onServiceDisconnected(ComponentName name) {


        }
    }


    public void ad(View view) {
      //  wManager.removeView(views);
     //   wManager.addView(views,wmParams);

    }

    @Override
    protected void onResume() {

        super.onResume();
    }
}